use "HHS_JSJ_2019_replication_data.dta", clear
tab source
tab type

*** Table 1 
** Model 1
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 0, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modP
** Model 2
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 2, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modA
** Model 3
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 1, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modR
*** Model 4
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type != ., link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modPooled
estat ic
estout modP modA modR modPooled, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05) 


*** Figure 1
*kdensity cos2sct if type != ., xline(.865) text(2.1 .95 "ACLU brief")  text(1.9 .95 "Mapp v. Ohio") xtitle(Cosine Similarity Score, col(black)) title("", color(black)) xsize(6) ysize(4) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))

*** Figure 2 values
xtile simDecile = cos2sct, nq(10)
sort type simDecile
by type simDecile: sum overlapWords, detail
by type simDecile: sum overlapCites, detail

*** FN 11: excluding briefs from archives
** Model 1, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 0 & source != "Hard Copy", link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modP2
estout modP modP2, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05) 
** Model 2, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 2 & source != "Hard Copy", link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modA2
estout modA modA2, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)
** Model 3, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 1 & source != "Hard Copy", link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modR2
estout modR modR2, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)

*** FN 12: including amicus for neither party (but taking out controls for filerWon and ideological congruence)
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc numBriefs filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type2 == 2, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modA3
estout modA modA3, cells("b(star fmt(3)) se(fmt(3) par) p(fmt(3))") starlevels(* 0.05)

*** FN 17: results are robust to not combining negations 
** Model 1, not collapsing negations for Overal Novelty of Laguage measure
glm cos2sct c.tfidf_norm_50_100Alt c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 0, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modP4
estout modP modP4, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05) 
** Model 2, not collapsing negations for Overal Novelty of Laguage measure
glm cos2sct c.tfidf_norm_50_100Alt c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 2, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modA4
estout modA modA4, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)
** Model 3, not collapsing negations for Overal Novelty of Laguage measure
glm cos2sct c.tfidf_norm_50_100Alt c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 1, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modR4
estout modR modR4, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)
** Model 4, not collapsing negations for Overal Novelty of Laguage measure
glm cos2sct c.tfidf_norm_50_100Alt c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type != ., link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modPooled4
estout modR modR4, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)

*** FN 20: excluding consolidated cases
** Model 1, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 0 & consolidated == 0, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modP5
estout modP modP5, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05) 
** Model 2, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 2 & consolidated == 0, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modA5
estout modA modA5, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)
** Model 3, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 1 & consolidated == 0, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modR5
estout modR modR5, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)

*** FN 21: author ideology instead of median of the majority
** Model 1, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc auAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 0, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modP6
estout modP modP6, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05) 
** Model 2, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc auAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 2, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modA6
estout modA modA6, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)
** Model 3, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc auAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type == 1, link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modR6
estout modR modR6, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)
** Model 4, electronic briefs only
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc auAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity if type != ., link(logit) family(binomial) robust cluster(caseLexCite)
estimates store modPooled6
estout modR modR6, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05)

** Summary Statistics
sum tfidf_norm_50_100 cfidf_norm_50th uWCK totalUCites dupWCK dupTotalCites majMedAligned cos2lc numBriefs wordLog_zscore complexity if type != ., detail
tab filerWon if type != ., mis
tab filerSG if type != ., mis
tab filerState if type != ., mis
tab filerElite if type != ., mis
tab oneRegFiler if type != ., mis

*** Quantites of interest reported in the text of the "Results" section
**Change Overall Novelty of Language from 25th to 75th percentile value, amicus briefs:  -0.034
estimates restore modA
margins, at(tfidf_norm_50_100=(0.006 0.010) cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )  post contrast(atcontrast(ar._at))

**Change Shared Citations from 25th to 75th percentile value, amicus briefs: 0.025
estimates restore modA
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=(11 42) cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )  post contrast(atcontrast(ar._at))

**Change Similarity to Lower court opinion from 25th to 75th percentile value, main party briefs: 0.019
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=(0.364 0.610) majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )  post contrast(atcontrast(ar._at))

**Change Ideological Congruence from 25th to 75th percentile value, main party briefs: 0.003
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=(-0.921 0.952) numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )  post contrast(atcontrast(ar._at))


** Predicted probability (and CI) for each type of brief
*Party: 0.629 (0.619, 0.638)
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )  

*Reply: 0.606 (0.596, 0.617)
estimates restore modR
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )  

*Amicus: 0.554 (0.545, 0.563)
estimates restore modA
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )  

**Change Ideological Congruence min and max, main party briefs: Min: 0.623, Max: 0.634
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=(-3.473 3.173) numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )

**Change Overall Novelty of Language min and max, main party briefs: Min: 0.711 Max: 0.095
estimates restore modP
margins, at(tfidf_norm_50_100=(0 0.0677) cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 )  


gen where = 0
gen where2 = -0.1
gen pipe = "|"

*** Figure 3
* Plot effect of Overall Novelty-Words
*Party
estimates restore modP
margins, at(tfidf_norm_50_100=(0 .01 .02 .03 .04 .05 .06 .07) cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where tfidf_norm_50_100 if type == 0, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1) xlab(0(.01).07) ytitle(Predicted Similarity) xtitle(Overall Novelty - Words) title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Reply
estimates restore modR
margins, at(tfidf_norm_50_100=(0 .01 .02 .03 .04 .05 .06 .07) cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where tfidf_norm_50_100 if type == 1, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(.01).07) ytitle(Predicted Similarity) xtitle(Overall Novelty - Words) title(Reply Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Amicus
estimates restore modA
margins, at(tfidf_norm_50_100=(0 .01 .02 .03 .04 .05 .06 .07) cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where tfidf_norm_50_100 if type == 2, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(.01).07) ytitle(Predicted Similarity) xtitle(Overall Novelty - Words) title(Amicus Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )


* Plot effect of Overall Novelty-Cites
*Party
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=(0(.1)1.5) uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where cfidf_norm_50th if type == 0, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1) xlab(0(.2)1.5) ytitle(Predicted Similarity) xtitle(Overall Novelty - Cites) title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Reply
estimates restore modR
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=(0(.1)1.5) uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where cfidf_norm_50th if type == 1, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(.2)1.5) ytitle(Predicted Similarity) xtitle(Overall Novelty - Cites) title(Reply Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Amicus
estimates restore modA
margins, at( tfidf_norm_50_100=.008 cfidf_norm_50th=(0(.1)1.5) uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where cfidf_norm_50th if type == 2, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(.2)1.5) ytitle(Predicted Similarity) xtitle(Overall Novelty - Cites) title(Amicus Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )

*** Figure 4
* Plot effect of Unique Words
*Party
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=(0(.1)1.9) totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where uWCK if type == 0, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1) xlab(0(.2)1.8) ytitle(Predicted Similarity) xtitle("Unique Words (in thousands)") title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Reply
estimates restore modR
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=(0(.1)1.9) totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where uWCK if type == 1, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(.2)1.8) ytitle(Predicted Similarity) xtitle("Unique Words (in thousands)") title(Reply Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Amicus
estimates restore modA
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=(0(.1)1.9) totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where uWCK if type == 2, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(.2)1.8) ytitle(Predicted Similarity) xtitle("Unique Words (in thousands)") title(Amicus Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )


* Plot effect of Unique Cites
*Party
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=(0(5)114) dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where totalUCites if type == 0,    yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1) xlab(0(10)110) ytitle(Predicted Similarity) xtitle(Unique Cites) title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0)  )
* Reply
estimates restore modR
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=(0(5)114) dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where totalUCites if type == 1,   yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(10)110) ytitle(Predicted Similarity) xtitle(Unique Cites) title(Reply Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Amicus
estimates restore modA
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=(0(5)114) dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where totalUCites if type == 2,   yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(10)110) ytitle(Predicted Similarity) xtitle(Unique Cites) title(Amicus Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )

*** Figure 5
* Plot effect of Duplicate Words
*Party
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=(0(3)37) dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where dupWCK if type == 0, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1) xlab(0(5)35) ytitle(Predicted Similarity) xtitle("Duplicate Words (in thousands)") title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Reply
estimates restore modR
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=(0(3)37) dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where dupWCK if type == 1, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(5)35) ytitle(Predicted Similarity) xtitle("Duplicate Words (in thousands)") title(Reply Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Amicus
estimates restore modA
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=(0(3)37) dupTotalCites=23 cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where dupWCK if type == 2, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(5)35) ytitle(Predicted Similarity) xtitle("Duplicate Words (in thousands)") title(Amicus Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )

* Plot effect of Duplicate Cites
*Party
estimates restore modP
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=(0(10)212) cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where dupTotalCites if type == 0, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1) xlab(0(20)210) ytitle(Predicted Similarity) xtitle(Duplicate Cites) title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Reply
estimates restore modR
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=(0(10)212) cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where dupTotalCites if type == 1, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(20)210) ytitle(Predicted Similarity) xtitle(Duplicate Cites) title(Reply Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )
* Amicus
estimates restore modA
margins, at(tfidf_norm_50_100=.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=(0(10)212) cos2lc=0.497 majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plot1opts(lwidth(medthick) lcolor(black)) recastci(rarea)  ciopts(fcolor(gs10) lcolor(gs10)) addplot(scatter where dupTotalCites if type == 2, yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)  xlab(0(20)210) ytitle(Predicted Similarity) xtitle(Duplicate Cites) title(Amicus Briefs, color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) msymbol(none) mlabel(pipe) mlabsize(vsmall) mlabcolor(black) mlabposition(0) )

*** Figure 6
* Lower court and Ideological Congruence, predicted outcomes
estimates restore modP
margins, at(tfidf_norm_50_100=0.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=(0(.1)1) majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10))  yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1) xlab(0(.2)1) ytitle(Predicted Similarity) xtitle(Similarity to Lower Court Opinion) title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off)  

estimates restore modP
margins, at(tfidf_norm_50_100=0.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=(-3.4(.2)3.4) numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10))  yscale(range(0 1)) ytick(0(.2)1) ylab(0(.2)1)   xtick(-3.5(.5)3.5) xlab(-3.5(.5)3.5) ytitle(Predicted Similarity) xtitle(Ideological Congruence) title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) 

*Marginal Effects
estimates restore modP
margins, dydx(cos2lc) at(tfidf_norm_50_100=0.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=(0(.1)1) majMedAligned=0.072 numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10))  yscale(range(0 .2)) ytick(0(.05).2) ylab(0(.05).2) xtick(0(.2)1) xlab(0(.2)1) ytitle(Marginal Effect) xtitle(Similarity to Lower Court Opinion) title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off)  

estimates restore modP
margins, dydx(majMedAligned) at(tfidf_norm_50_100=0.008 cfidf_norm_50th=0.021 uWCK=0.23 totalUCites=5 dupWCK=7.08 dupTotalCites=23 cos2lc=0.497 majMedAligned=(-3.4(.2)3.4) numBriefs=10 filerWon=1 filerSG=0 filerState=0 filerElite=0 oneRegFiler=1 wordLog_zscore=0.165 complexity=3 ) 
marginsplot, recast(line)  plotopts(lwidth(medthick) lcolor(black)) recastci(rarea) ciopts(fcolor(gs10) lcolor(gs10))  yscale(range(0 .2)) ytick(0(.05).2) ylab(0(.05).2) xtick(-3.5(.5)3.5) xlab(-3.5(.5)3.5) ytitle(Marginal Effect) xtitle(Ideological Congruence) title("Main Party Briefs", color(black)) xsize(3) ysize(2.25) graphregion(lcolor(black) lwidth(thick)) graphregion(fcolor(white))  legend(off) 


*** Appendix B
** Table B1
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity dupWCcase dupCitescase  if type == 0, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modP_B1
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity dupWCcase dupCitescase  if type == 2, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modA_B1
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity dupWCcase dupCitescase  if type == 1, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modR_B1
estout modP_B1 modA_B1 modR_B1 , cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05) 

** Table B2
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filer*Elite oneRegFiler wordLog_zscore complexity dupWCcase2 dupCitescase2 if type == 0, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modP_B2
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity dupWCcase2 dupCitescase2 if type == 2, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modA_B2
glm cos2sct c.tfidf_norm_50_100 c.cfidf_norm_50th c.uWCK c.totalUCites c.dupWCK c.dupTotalCites cos2lc majMedAligned numBriefs filerWon filerSG filerState filerElite oneRegFiler wordLog_zscore complexity dupWCcase2 dupCitescase2 if type == 1, link(logit) family(binomial) robust cluster(caseLexCite)
estat ic
estimates store modR_B2
estout modP_B2 modA_B2 modR_B2, cells(b(star fmt(3)) se(fmt(3) par)) starlevels(* 0.05) 



